Expand description
This crate provides to an interface into the linux procfs
filesystem, usually mounted at
/proc
.
This is a pseudo-filesystem which is available on most every linux system and provides an interface to kernel data structures.
Kernel support
Not all fields/data are available in each kernel. Some fields were added in specific kernel
releases, and other fields are only present in certain kernel configuration options are
enabled. These are represented as Option
fields in this crate.
This crate aims to support all 2.6 kernels (and newer). WSL2 is also supported.
Documentation
In almost all cases, the documentation is taken from the
proc.5
manual page. This means that
sometimes the style of writing is not very “rusty”, or may do things like reference related files
(instead of referencing related structs). Contributions to improve this are welcome.
Panicing
While previous versions of the library could panic, this current version aims to be panic-free
in a many situations as possible. Whenever the procfs crate encounters a bug in its own
parsing code, it will return an InternalError
error. This should be considered a
bug and should be reported. If you encounter a panic,
please report that as well.
Cargo features
The following cargo features are available:
chrono
– Default. Optional. This feature enables a few methods that return values asDateTime
objects.flate2
– Default. Optional. This feature enables parsing gzip compressed/proc/config.gz
file via theprocfs::kernel_config
method.backtrace
– Optional. This feature lets you get a stack trace whenever anInternalError
is raised.
Examples
Examples can be found in the various modules shown below, or in the examples folder of the code repository.
Re-exports
pub use crate::sys::kernel::BuildInfo as KernelBuildInfo;
pub use crate::sys::kernel::Type as KernelType;
pub use crate::sys::kernel::Version as KernelVersion;
Modules
/proc/sys/
directory is there so that you don’t even need special tools to do it!Structs
/proc/cpuinfo
./proc/stat
/proc/meminfo
file./proc/sysvipc/shm
Relation with [crate::process::process::MMapPath::Vsys]
/proc/uptime
file.Enums
Functions
DateTime
object.